{if $GLOBALS.is_ajax || $smarty.get.ajax_submit}

	{foreach from=$errors key=key item=error}
		{if $key == 'NOT_SUPPORTED_VIDEO_FORMAT' || $key == 'NOT_ACCEPTABLE_FILE_FORMAT'}
			<p class="error">[[Not supported video format]]</p>
		{else}
			<p class="error">{$key}</p>
		{/if}
	{/foreach}

	<div id="classifieds_video_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}">
	{if $complexField && $filesInfo.$complexStep.file_name ne null}
		<div class="complex-view-file-caption">
			{$filesInfo.$complexStep.file_name} ({$filesize|string_format:"%.2f"} {$size_token})
			|
			{if $copy_listing ne null}
				{*<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}">[[Remove]]</a>
				<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />*}
			{else}
				<a class="delete_video_complex"
				   form_token="{$form_token}"
					 listing_id="{if $listing_id}{$listing_id}{else}{$listing.id}{/if}"
					 field_id="{$complexField}:{$id}:{$complexStep}"
					 file_id="{$filesInfo.$complexStep.file_id}"
					 href="{$GLOBALS.site_url}/classifieds/delete-complex-file/?listing_id={$listing.id}&amp;field_id={$complexField}:{$id}:{$complexStep}&amp;file_id={$filesInfo.$complexStep.file_id}&amp;form_token={$form_token}">[[Remove]]</a>

			{/if}
			<br/><br/>
		</div>
		<input type="hidden"
			   field_id="{$id}"
			   field_action="upload_classifieds_video"
			   field_target="video_field_content_{$id}"
			   id="hidden_{$complexField}[{$id}][{$complexStep}]"
			   name="{$complexField}[{$id}][{$complexStep}]"
			   value="{$filesInfo.$complexStep.file_id}"
			   class="complexField"/>

	{elseif !$complexField && $value.file_name ne null && $url != '/add-listing/'}
		{$value.file_name} ({$filesize|string_format:"%.2f"} {$size_token})
		|
		{if $copy_listing ne null}
			<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;token={$form_token}">[[Remove]]</a>
			<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />
		{else}
			<a class="delete_classifieds_video"
			   form_token="{$form_token}"
			   listing_id="{if $listing_id}{$listing_id}{else}{$listing.id}{/if}"
			   field_id="{$id}" file_id="{$value.file_id}"
			   href="{$GLOBALS.site_url}/classifieds/delete-uploaded-file/?listing_id={$listing.id}&amp;field_id={$id}&amp;form_token={$form_token}">[[Remove]]</a>
		{/if}
		<br/><br/>
	{/if}
	</div>

    <input type="file"
		   field_id="{if $complexField}{$complexField}:{$id}:{$complexStep}{else}{$id}{/if}"
		   field_action="upload_classifieds_video{if $complexField}_complex{/if}"
		   field_target="video_field_content_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
		   name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
		   class="autouploadField {if $complexField}complexField{/if}"
		   id="input_video_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
		   {if ($complexField && $filesInfo.$complexStep.file_name ne null) || (!$complexField && $value.file_name ne null)}style="display:none;"{/if} />

{else}


	<div id="video_field_content_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}">
		
		<div class="errors"></div>

		<div id="classifieds_video_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}">
		{if $complexField && $filesInfo.$complexStep.file_name ne null}
			<div class="complex-view-file-caption">
				<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?listing_id={$listing.id}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listing.id}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}"> [[Watch a video]]</a>
				|
				{if $copy_listing ne null}
					{*<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}">[[Remove]]</a>
					<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />*}
				{else}
					<a class="delete_video_complex"
					   form_token="{$form_token}"
						 listing_id="{if $listing_id}{$listing_id}{else}{$listing.id}{/if}"
						 field_id="{$complexField}:{$id}:{$complexStep}"
						 file_id="{$filesInfo.$complexStep.file_id}"
						 href="{$GLOBALS.site_url}/classifieds/delete-complex-file/?listing_id={$listing.id}&amp;field_id={$complexField}:{$id}:{$complexStep}&amp;file_id={$filesInfo.$complexStep.file_id}&amp;form_token={$form_token}">[[Remove]]</a>
				{/if}
				<br/><br/>
			</div>
			<input type="hidden"
				   id="hidden_{$complexField}[{$id}][{$complexStep}]"
				   name="{$complexField}[{$id}][{$complexStep}]"
				   value="{$filesInfo.$complexStep.file_id}"
				   class="complexField"/>
		{elseif !$complexField && $value.file_name ne null && $url != '/add-listing/'}
			<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?listing_id={$listing.id}&amp;field_id={$id}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listing.id}&amp;field_id={$id}"> [[Watch a video]]</a>
			|
			{if $copy_listing ne null}
				<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;token={$form_token}">[[Remove]]</a>
				<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />
			{else}
				<a class="delete_classifieds_video"
				   form_token="{$form_token}"
				   listing_id="{if $listing_id}{$listing_id}{else}{$listing.id}{/if}"
				   field_id="{$id}"
				   file_id="{$value.file_id}"
				   href="{$GLOBALS.site_url}/classifieds/delete-uploaded-file/?listing_id={$listing.id}&amp;field_id={$id}&amp;form_token={$form_token}">[[Remove]]</a>
			{/if}
			<br/><br/>
		{/if}
		</div>

		<input type="file"
			   field_id="{if $complexField}{$complexField}:{$id}:{$complexStep}{else}{$id}{/if}"
			   field_action="upload_classifieds_video{if $complexField}_complex{/if}"
			   field_target="video_field_content_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
			   name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
			   class="autouploadField {if $complexField}complexField{/if}"
			   id="input_video_{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
			   {if ($complexField && $filesInfo.$complexStep.file_name ne null) || (!$complexField && $value.file_name ne null)}style="display:none;"{/if} />

        {if ($complexField && $filesInfo.$complexStep.file_name eq null)}
            <input type="hidden" field_id="{$id}" field_action="upload_classifieds_video" field_target="video_field_content_{$id}" id="hidden_{$complexField}[{$id}][{$complexStep}]" name="{$complexField}[{$id}][{$complexStep}]" value="" class="complexField"/>
        {/if}
	</div>


	<script>
		{literal}

		// check temporary uploaded data of field
		$(function() {
			{/literal}
			{if $complexField}
				getComplexClassifiedsVideoData('{$complexField}[{$id}][{$complexStep}]', '{if $listing_id}{$listing_id}{else}{$listing.id}{/if}', '{if $listing.type.id}{$listing.type.id}{/if}', '{$form_token}');
			{else}
				getClassifiedsVideoData('{$id}', '{if $listing_id}{$listing_id}{else}{$listing.id}{/if}', '{$form_token}');
			{/if}
			{literal}
		});

		{/literal}
	</script>

{/if}

